package com.iscreen.dbupgrade;

import com.iscreen.dbupgrade.queries.ShowTableQuery;
import com.iscreen.utils.db.connection.DBConnection;
import com.iscreen.utils.db.query.Query;
import com.iscreen.utils.exceptions.IScreenException;

public abstract class SchemaUtils
{
	public static boolean isTableExists(DBConnection connection,
			String tableName) throws IScreenException
	{
		ShowTableQuery showTable = DBUpgrade.getInstance().getFactory()
				.getQueryFactory().createShowTableQuery(tableName);
		Query query = connection.createQuery(showTable.getSql());
		try
		{
			query.open();
			if (query.next())
			{
				return true;
			}
			else
			{
				return false;
			}
		}
		finally
		{
			query.close();
		}
	}

}
